console.clear();

//--------Consts--------//
const loadScreen = UiScreen.getAllScreen().find(obj => obj.name === 'Welcome')
const play = loadScreen?.findChildByName<UiImage>("play")
const quit = loadScreen?.findChildByName<UiImage>("quit")
const DVloper = loadScreen?.findChildByName<UiImage>("title")?.findChildByName<UiImage>("DVloper")
const title = loadScreen?.findChildByName<UiText>("title")
const Teddy = loadScreen?.findChildByName<UiImage>("Teddy")
const Radiation = loadScreen?.findChildByName<UiImage>("Radiation")
//--------Consts--------//
if (!play || !quit || !DVloper || !title || !Teddy || !Radiation || !loadScreen) {
    console.error("One or more UI elements not found. Please check the names and ensure they are correctly set in the UI editor.")
    throw new Error("UI initialization failed.");
}
//--------Tick--------//
// 判断接收到的事件参数是否为 "UIstart"
play.visible = true; // 如果是 "UIstart"，则显示 play 对象
quit.visible = true; // 显示 quit 对象
DVloper.visible = true; // 显示 DVloper 对象
title.visible = true; // 显示 title 对象
Teddy.visible = true; // 显示 Teddy 对象
Radiation.visible = true; // 显示 Radiation 对象
//--------Use--------//
play.events.on("pointerup", () => {
    remoteChannel.sendServerEvent("play");
    loadScreen.visible = false; // Hide the load screen after clicking play
});
quit.events.on("pointerup", () => {
    remoteChannel.sendServerEvent("quit");
});
DVloper.events.on("pointerup", () => {
    remoteChannel.sendServerEvent("DVloper");
});
Teddy.events.on("pointerup", () => {
    remoteChannel.sendServerEvent("Teddy");
});

Radiation.events.on("pointerup", () => {
    remoteChannel.sendServerEvent("Radiation");
});